﻿using System.Collections;
using System.Collections.Generic;
using INTEX.DataBase.Tools;
using ReflectionStudio.Core;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.IO;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
   
    public partial class ITXEXRPT
    {
        public string AFSPrint(ref bool IsReturn)
        {
            if (app.company != "AFS")
                return filename;
            Helper.GetDate(ref date, ref year, ref month, ref day);
            switch (DocType)
            {

                case "AFSEXAPP":
                    destfolder = SetFolder(Root, "SampleList");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("ICC_EXORD"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["ICC_EXORD"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    KRS = dwOrder["VKPAUFKRS"].ToString().Trim();
                    LFD = dwOrder["VKPAUFLFD"].ToString().Trim();
                    order = KRS + Helper.GetSubRollNum(LFD);
                    DestFile = destfolder + "\\sl-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "AFSEXORD";
                    exAgent.CreateNewSheet(temp + "SL.xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    AFSEXAPP(dsSource);
                    break;

                case "AFSARTLIST":
                    destfolder = SetFolder(Root, "ArticleList");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("VAART"))
                        IsReturn = true;
                    DestFile = destfolder + "\\ArticleList-" + date + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "AFSARTLIST";
                    exAgent.CreateNewSheet(temp + "ART.xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    AFSARTLIST(dsSource);
                    break;
                case "AFSEXAPP1":
                    destfolder = SetFolder(Root, "SampleList");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("ICC_EXORD"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["ICC_EXORD"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    KRS = dwOrder["VKPAUFKRS"].ToString().Trim();
                    LFD = dwOrder["VKPAUFLFD"].ToString().Trim();
                    order = KRS + Helper.GetSubRollNum(LFD);
                    DestFile = destfolder + "\\sl-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "AFSEXORD1";
                    exAgent.CreateNewSheet(temp + "SL.xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    AFSEXAPP1(dsSource);
                    break;
                case "AFSEXAPP3":
                    destfolder = SetFolder(Root, "SampleList");
                    #region====文件命名==============
                    if (!dsSource.Tables.Contains("ICC_EXORD"))
                        IsReturn = true;
                    dwOrder = dsSource.Tables["ICC_EXORD"].Rows[0];
                    if (dwOrder == null)
                    {
                        IsReturn = true;
                    }
                    KRS = dwOrder["VKPAUFKRS"].ToString().Trim();
                    LFD = dwOrder["VKPAUFLFD"].ToString().Trim();
                    order = KRS + Helper.GetSubRollNum(LFD);
                    DestFile = destfolder + "\\sl-" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "AFSEXORD3";
                    exAgent.CreateNewSheet(temp + "SL.xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    AFSEXAPP3(dsSource);
                    break;
                case "VALBTYP":
                    destfolder = SetFolder(Root, "Lab");
                    #region====文件命名==============
                    order = DateTime.Now.ToLocalTime().ToFileTime().ToString();
                    DestFile = destfolder + "\\lab" + order + ".xls";
                    #endregion
                    #region=====空白文档=======
                    Standard = "VALBTYP";
                    exAgent.CreateNewSheet(temp + ".xls", Standard);
                    tempfile = exAgent.FileName;
                    #endregion
                    VALBTYP(dsSource);
                    break;
            }
            return filename;
        }

    }
}
